Repository list: in_use_mode alias + repository_summary denormalization#3
Draft
Repository list: in_use_mode alias + repository_summary denormalization#3
Conversation
Add parseRepositoryListInUseQuery so in_use_mode=in_use_newer maps to the same filter as in_use. Document in_use vs in_use_mode precedence in Swagger. Repository list remains boolean InUse-only in the state store; semver rules apply only to per-repository tag views. Co-authored-by: Stefan Knott <daimoniac@users.noreply.github.com>
Add repository_summary with indexes and an AFTER INSERT trigger on repositories. Backfill on store open when counts drift or rows have updated_at=0. Refresh summary on RecordScan, cluster inventory sync/delete, whitelist changes, artifact digest cleanup, and excess scan cleanup. Rewrite ListRepositories to JOIN repository_summary with SQL filters and LIMIT/OFFSET. Repair uninitialized summary rows lazily on list for test DBs that insert repositories directly. Co-authored-by: Stefan Knott <daimoniac@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements the attached plan in two commits.
Commit 1: API semantics for repository listing
parseRepositoryListInUseQuerysoin_use_mode=in_use_newer(and hyphen variants) maps to the same filter as in-use, whilein_usestill wins when both query params are present.in_usevsin_use_modeon GET/api/v1/repositoriesin Swagger annotations (regenerate in CI/Docker viamake swagger;build/is gitignored).Commit 2:
repository_summaryfor fast list + paginationrepository_summarytable (FK torepositoriesON DELETE CASCADE), indexes, and anAFTER INSERTtrigger to seed a summary row for each new repository.ensureRepositorySummariesruns after schema init: seeds missing rows and full backfill when there is drift orupdated_at = 0.refreshRepositorySummaryrecomputes scan aggregates plusruntime_used(via existingrepositoryRuntimeUsageByID) andwhitelisted.RecordScan,RecordClusterInventory+DeleteClusterInventory(full runtime refresh), whitelist add/remove,CleanupArtifactScans,CleanupExcessScans.ListRepositoriesreads fromrepository_summarywith SQLWHERE,ORDER BY,LIMIT/OFFSET, and a matchingCOUNT(*).repairRepositorySummariesForListruns at the start ofListRepositoriesonly when uninitialized rows exist (updated_at = 0), so tests that insertrepositoriesdirectly still get populated summaries without scanning every list in production.Tests
internal/api/repository_list_in_use_query_test.gofor query parsing.internal/statestore/sqlite_repository_summary_test.gofor RecordScan + summary + list consistency.repository_summary.